var locomotive = require('locomotive');
var Controller = locomotive.Controller;

var testController = new Controller();

testController.before('main', function(next) {
    next();
});

testController.main = function() {
    var self = this;
    var apiClient = this.req.apiClient;
    console.log(apiClient);

    var name = this.param("name");
    console.log("------get request param name=" + name + "---------------");

    var self = this;

    var message = "  name= " + name;
    var result = {status: 1, msg: message};
    this.respond({
        'json': function () {
            self.res.jsonp(result);
        }
    })
}

testController.before('testPutMethod', function(next) {
    next();
});

testController.testPutMethod = function(){
    var self = this;

    var url  = this.param("url");
    console.log("-----url= " + url + "---");

    var result = {status: 1, msg: "huang"};
    this.respond({
        'json': function () {
            self.res.jsonp(result);
        }
    })
}

module.exports = testController;